<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <script>
        var lists = [{name:"html",state:false}]
        /* localStorage 特点:只能村简单的数据 */
        var res = JSON.stringify(lists);

        /* localStorage.setItem("todo",res);
        var result = localStorage.getItem("todo");
        console.log(result)
        // console.log(JSON.parse(result)) */

        localStorage.setItem("todo","good");
        var result = localStorage.getItem("todo");
        /* 用正则判断是数组还是对象 */
        var reg = /^[{\[].+[}\]]$/  
        // console.log(result)
        // console.log(JSON.parse(result))
        console.log(reg.test(res))//true
    </script>
</body>
</html>